{dialog.object}graphQLQuery Method
Syntax
{dialog.object}.graphQLQuery(url, queryDefinition, variables, headers, queryParameters, onSuccess, onFail)
Arguments
- urlstring
The URL of the service (e.g. http://www.mygraphqlservice.com/northwind.a5svc)
- queryDefinitionstring
The string that defines the query
- variablesobject
An object that defines values for each of the query variables.
var variables = {"customerId":"BOLID"};
- headersobject array
An array of objects. Each object in the array has a name and value property. Used when the service requires authentication using an api key that must be passed in the header of the request.
var headers = [ {"name":"apikey","value":"XXXXXXXXXXXXXXXXXXXX"}, {"name":"myHeader","value":"my header value"} ];
- queryParametersstring
A string of name=value pairs. Used when the service requires authentication via an api key that must be passed as a query parameter.
var queryParams = "apikey=XXXXXXXXXXXXX&myQueryParam=query%20param%20value";
- onSuccessfunction
The callback function to call once the data is returned.
- onFailfunction
The callback function to call if there is an error.
Description
Executes a GraphQL query.
Discussion
The {dialog.object}.graphQLQuery() method executes a GraphQL query directly from the client's browser, avoiding a callback to the Alpha Anywhere application server.
Example
var url = 'http://www.mygraphqlservice.com/northwind.a5svc'; var query = ` { GetManyCustomers { records { CustomerID ContactName CompanyName City Country } } } ` var onSuccess = function() {}; var onFail = function() {}; {dialog.object}.graphQLQuery(url,query,"","","",onSuccess,onFail);
See Also